package main

import (
	"fmt"
)

type Sorter interface{
	Len() int
	Less(i,j int)bool
	Swap(i,j int)
}

type Xi []int
type Xs []string

func (i Xi)Len() int{
	return len(i)
}
func (p Xi)Less(i,j int)bool{
	return p[i]<p[j]
}
func (p Xi)Swap(i,j int){
	p[i],p[j]=p[j],p[i]
}

func (s Xs)Len() int{
	return len(s)
}
func (s Xs)Less(i,j int)bool {
	return s[i]<s[j]
}
func (s Xs)Swap(i,j int){
	s[i],s[j]=s[j],s[i]
}

func Sort(x Sorter){
	for i:=0;i<x.Len()-1;i++{
		for j:=i+1;j<x.Len();j++{
			if x.Less(i,j){
				x.Swap(i,j)
			}
		}
	}
}

func main(){
	ints:=Xi{44, 67, 3, 17, 89, 10, 73, 9, 14, 8}
	strs:=Xs{"nut", "ape", "elephant", "zoo", "go"}
	Sort(ints)
	fmt.Println("sort : ",ints)
	Sort(strs)
	fmt.Println("sort : ",strs)
}